use once_cell::sync::Lazy;

pub mod sys;
pub const GITCODE_API_URL: &str = "https://api.gitcode.com/api/v5";

static TOKEN: Lazy<String> = Lazy::new(|| {
    std::env::var("GITCODE_TOKEN_TOOLS")
        .unwrap_or_else(|e| panic!("请先设置有效的环境变量 GITCODE_TOKEN_TOOLS: {}", e))
});

static CLIENT: Lazy<reqwest::Client> = Lazy::new(|| reqwest::Client::new());

static HEADERS: Lazy<reqwest::header::HeaderMap> = Lazy::new(|| {
    let mut headers = reqwest::header::HeaderMap::new();
    // headers.insert("Content-Type", "application/json".parse().unwrap());
    headers.insert(
        "Authorization",
        format!("Bearer {}", &*TOKEN).parse().unwrap(),
    );
    headers
});

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        println!("{}", GITCODE_API_URL);
    }
}
